using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class LookupsInfo
    {
		#region Local Variable
		public enum Field
		{
			Category,
			Code,
			Description,
			Description1,
			Altermate,
			Status,
			CREATEDBY,
			MODIFIEDBY,
			CREATEDDATE,
			MODIFIEDDATE
		}
		private String _Category;
		private String _Code;
		private String _Description;
		private String _Description1;
		private String _Altermate;
		private String _Status;
		private String _CREATEDBY;
		private String _MODIFIEDBY;
		private Int32 _CREATEDDATE;
		private Int32 _MODIFIEDDATE;
		
		public String Category{	get{ return _Category;} set{_Category = value;} }
		public String Code{	get{ return _Code;} set{_Code = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		public String Description1{	get{ return _Description1;} set{_Description1 = value;} }
		public String Altermate{	get{ return _Altermate;} set{_Altermate = value;} }
		public String Status{	get{ return _Status;} set{_Status = value;} }
		public String CREATEDBY{	get{ return _CREATEDBY;} set{_CREATEDBY = value;} }
		public String MODIFIEDBY{	get{ return _MODIFIEDBY;} set{_MODIFIEDBY = value;} }
		public Int32 CREATEDDATE{	get{ return _CREATEDDATE;} set{_CREATEDDATE = value;} }
		public Int32 MODIFIEDDATE{	get{ return _MODIFIEDDATE;} set{_MODIFIEDDATE = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public LookupsInfo()
		{
			_Category = "";
			_Code = "";
			_Description = "";
			_Description1 = "";
			_Altermate = "";
			_Status = "";
			_CREATEDBY = "";
			_MODIFIEDBY = "";
			_CREATEDDATE = 0;
			_MODIFIEDDATE = 0;
		}
		public LookupsInfo(
		String Category,
		String Code,
		String Description,
		String Description1,
		String Altermate,
		String Status,
		String CREATEDBY,
		String MODIFIEDBY,
		Int32 CREATEDDATE,
		Int32 MODIFIEDDATE
		)
		{
			_Category = Category;
			_Code = Code;
			_Description = Description;
			_Description1 = Description1;
			_Altermate = Altermate;
			_Status = Status;
			_CREATEDBY = CREATEDBY;
			_MODIFIEDBY = MODIFIEDBY;
			_CREATEDDATE = CREATEDDATE;
			_MODIFIEDDATE = MODIFIEDDATE;
		}
		public LookupsInfo(DataRow dr)
		{
			if (dr != null)
			{
				_Category = dr[Field.Category.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Category.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Description1 = dr[Field.Description1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description1.ToString()]);
				_Altermate = dr[Field.Altermate.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Altermate.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
				_CREATEDBY = dr[Field.CREATEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEDBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDDATE = dr[Field.CREATEDDATE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.CREATEDDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public LookupsInfo(LookupsInfo objEntr)
		{			
			_Category = objEntr.Category;			
			_Code = objEntr.Code;			
			_Description = objEntr.Description;			
			_Description1 = objEntr.Description1;			
			_Altermate = objEntr.Altermate;			
			_Status = objEntr.Status;			
			_CREATEDBY = objEntr.CREATEDBY;			
			_MODIFIEDBY = objEntr.MODIFIEDBY;			
			_CREATEDDATE = objEntr.CREATEDDATE;			
			_MODIFIEDDATE = objEntr.MODIFIEDDATE;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Lookups");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.Category.ToString(), typeof(String)),
				new DataColumn(Field.Code.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.Description1.ToString(), typeof(String)),
				new DataColumn(Field.Altermate.ToString(), typeof(String)),
				new DataColumn(Field.Status.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDBY.ToString(), typeof(String)),
				new DataColumn(Field.MODIFIEDBY.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDDATE.ToString(), typeof(Int32)),
				new DataColumn(Field.MODIFIEDDATE.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.Category.ToString()] = _Category;
			row[Field.Code.ToString()] = _Code;
			row[Field.Description.ToString()] = _Description;
			row[Field.Description1.ToString()] = _Description1;
			row[Field.Altermate.ToString()] = _Altermate;
			row[Field.Status.ToString()] = _Status;
			row[Field.CREATEDBY.ToString()] = _CREATEDBY;
			row[Field.MODIFIEDBY.ToString()] = _MODIFIEDBY;
			row[Field.CREATEDDATE.ToString()] = _CREATEDDATE;
			row[Field.MODIFIEDDATE.ToString()] = _MODIFIEDDATE;
			return row;
		}
        #endregion InitTable
    }
}
